package com.weds.test_service;

import com.weds.test_service.component.TestComponent;
import org.apache.camel.builder.RouteBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Description camel route
 * @Author lihw
 * @Date 2024/2/27 11:14
 */
@Component
public class CamelRoute extends RouteBuilder {

    @Autowired
    TestComponent testComponent;

    @Override
    public void configure() {

        // from("timer:foo?repeatCount=1")  请求一次
        // from("timer://foo?fixedRate=true&delay=0&period=10000") // 10s请求一次
        //         .to("http://127.0.0.1:10086/test/get_user")     // 测试接口
        //         .bean(testComponent, "dealUser");       // 处理逻辑



        rest("/say/hello")
                .get().route().transform().constant("Hello World");

        rest()
                .get("/hello")
                .produces("text/plain")
                .route()
                .transform().constant("Hello from Camel!");


    }

}
